<template>
  <div class="dashboard-container">
    <!-- 欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-text">
        <h1>欢迎回来，管理员</h1>
        <p>云校园管理系统为您提供全面的校园管理解决方案，今日有3条新消息待处理</p>
      </div>
      <div class="date-info">
        <div class="date">{{ currentDate }}</div>
        <div class="day">{{ currentDay }}</div>
      </div>
    </div>
    <!-- 主内容区域 -->
    <div class="tabs-container">
      <el-tabs v-model="tabActive" class="demo-tabs">
        <el-tab-pane label="首页概览" name="first">
          <div class="tab-content">
            <el-row :gutter="20">
              <el-col :span="16">
                <el-row :gutter="20">
                  <el-col :span="12">
                    <el-card>
                      <template #header>
                        <div class="card-header">
                          <div class="card-icon icon-statistic">
                            <el-icon size="24"><PieChart /></el-icon>
                          </div>
                          <div class="card-title">数据统计</div>
                        </div>
                      </template>
                      <div class="stats-grid">
                        <div class="stat-item">
                          <div class="stat-icon" style="background: #36d1dc;">
                            <el-icon size="22"><User /></el-icon>
                          </div>
                          <div class="stat-content">
                            <div class="stat-label">学生总数</div>
                            <div class="stat-value">2,842</div>
                            <div class="stat-trend trend-up">
                              <el-icon size="14"><Top /></el-icon> 5.2% 较上月
                            </div>
                          </div>
                        </div>
                        <div class="stat-item">
                          <div class="stat-icon" style="background: #5b86e5;">
                            <el-icon size="22"><User /></el-icon>
                          </div>
                          <div class="stat-content">
                            <div class="stat-label">教师人数</div>
                            <div class="stat-value">156</div>
                            <div class="stat-trend trend-up">
                              <el-icon size="14"><Top /></el-icon> 2.3% 较上月
                            </div>
                          </div>
                        </div>
                        <div class="stat-item">
                          <div class="stat-icon" style="background: #ff6b6b;">
                            <el-icon size="22"><Notebook /></el-icon>
                          </div>
                          <div class="stat-content">
                            <div class="stat-label">课程数量</div>
                            <div class="stat-value">78</div>
                            <div class="stat-trend trend-up">
                              <el-icon size="14"><Top /></el-icon> 8.7% 较上月
                            </div>
                          </div>
                        </div>
                        <div class="stat-item">
                          <div class="stat-icon" style="background: #4ecdc4;">
                            <el-icon size="22"><Monitor /></el-icon>
                          </div>
                          <div class="stat-content">
                            <div class="stat-label">今日访问</div>
                            <div class="stat-value">1,245</div>
                            <div class="stat-trend trend-down">
                              <el-icon size="14"><Bottom /></el-icon> 3.1% 较昨日
                            </div>
                          </div>
                        </div>
                      </div>
                    </el-card>
                  </el-col>
                  <el-col :span="12">
                    <el-card>
                      <template #header>
                        <div class="card-header">
                          <div class="card-icon icon-menu">
                            <el-icon size="24"><Grid /></el-icon>
                          </div>
                          <div class="card-title">快捷菜单</div>
                        </div>
                      </template>
                      <div class="quick-actions">
                        <div class="action-item" @click="navigateTo('message')">
                          <div class="action-icon" style="background: #36d1dc;">
                            <el-icon size="24"><Message /></el-icon>
                          </div>
                          <div class="action-text">消息中心</div>
                        </div>
                        <div class="action-item" @click="navigateTo('schedule')">
                          <div class="action-icon" style="background: #5b86e5;">
                            <el-icon size="24"><Calendar /></el-icon>
                          </div>
                          <div class="action-text">日程管理</div>
                        </div>
                        <div class="action-item" @click="navigateTo('score')">
                          <div class="action-icon" style="background: #ff6b6b;">
                            <el-icon size="24"><Document /></el-icon>
                          </div>
                          <div class="action-text">成绩管理</div>
                        </div>
                        <div class="action-item" @click="navigateTo('course')">
                          <div class="action-icon" style="background: #4ecdc4;">
                            <el-icon size="24"><Notebook /></el-icon>
                          </div>
                          <div class="action-text">课程管理</div>
                        </div>
                        <div class="action-item" @click="navigateTo('student')">
                          <div class="action-icon" style="background: #ffbe0b;">
                            <el-icon size="24"><User /></el-icon>
                          </div>
                          <div class="action-text">学生管理</div>
                        </div>
                        <div class="action-item" @click="navigateTo('analysis')">
                          <div class="action-icon" style="background: #fb5607;">
                            <el-icon size="24"><DataAnalysis /></el-icon>
                          </div>
                          <div class="action-text">数据分析</div>
                        </div>
                      </div>
                    </el-card>
                  </el-col>
                </el-row>
                <el-card>
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon icon-chart">
                        <el-icon size="24"><TrendCharts /></el-icon>
                      </div>
                      <div class="card-title">数据趋势分析</div>
                    </div>
                  </template>
                  <div class="chart-container">
                    <my-e-chart style="height: 400px; width: 100%"></my-e-chart>
                  </div>
                </el-card>
              </el-col>
              <el-col :span="8">
                <el-card>
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon icon-horn">
                        <el-icon size="24"><Bell /></el-icon>
                      </div>
                      <div class="card-title">系统公告</div>
                    </div>
                  </template>
                  <ul class="announcement-list">
                    <li class="announcement-item">
                      <div class="announcement-badge" style="background: #36d1dc;">
                        <el-icon><InfoFilled /></el-icon>
                      </div>
                      <div class="announcement-content">
                        <div class="announcement-title">系统维护通知</div>
                        <div class="announcement-time">10月15日 09:30</div>
                        <div class="announcement-desc">本周末将进行系统维护，请提前安排工作</div>
                      </div>
                    </li>
                    <li class="announcement-item">
                      <div class="announcement-badge" style="background: #5b86e5;">
                        <el-icon><Lightbulb /></el-icon>
                      </div>
                      <div class="announcement-content">
                        <div class="announcement-title">新功能上线</div>
                        <div class="announcement-time">10月12日 14:15</div>
                        <div class="announcement-desc">成绩分析模块已升级，新增多维度分析功能</div>
                      </div>
                    </li>
                    <li class="announcement-item">
                      <div class="announcement-badge" style="background: #ff6b6b;">
                        <el-icon><Calendar /></el-icon>
                      </div>
                      <div class="announcement-content">
                        <div class="announcement-title">教学评估提醒</div>
                        <div class="announcement-time">10月10日 16:45</div>
                        <div class="announcement-desc">本学期教学评估将于下周开始，请做好准备</div>
                      </div>
                    </li>
                    <li class="announcement-item">
                      <div class="announcement-badge" style="background: #4ecdc4;">
                        <el-icon><UserFilled /></el-icon>
                      </div>
                      <div class="announcement-content">
                        <div class="announcement-title">团队协作邀请</div>
                        <div class="announcement-time">10月8日 11:20</div>
                        <div class="announcement-desc">诚邀开发者加入云校园管理系统开发团队</div>
                      </div>
                    </li>
                  </ul>
                </el-card>

                <el-card style="margin-top: 20px;">
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon icon-task">
                        <el-icon size="24"><List /></el-icon>
                      </div>
                      <div class="card-title">待办事项</div>
                    </div>
                  </template>
                  <div class="tasks-container">
                    <div class="task-item">
                      <div class="task-checkbox">
                        <el-checkbox v-model="task1"></el-checkbox>
                      </div>
                      <div class="task-content">
                        <div class="task-title">审核新教师入职申请</div>
                        <div class="task-info">
                          <span>今天 14:00</span>
                          <span class="task-priority priority-high">高优先级</span>
                        </div>
                      </div>
                    </div>
                    <div class="task-item">
                      <div class="task-checkbox">
                        <el-checkbox v-model="task2"></el-checkbox>
                      </div>
                      <div class="task-content">
                        <div class="task-title">准备月度教学会议材料</div>
                        <div class="task-info">
                          <span>明天 10:00</span>
                          <span class="task-priority priority-medium">中优先级</span>
                        </div>
                      </div>
                    </div>
                    <div class="task-item">
                      <div class="task-checkbox">
                        <el-checkbox v-model="task3"></el-checkbox>
                      </div>
                      <div class="task-content">
                        <div class="task-title">检查系统安全更新</div>
                        <div class="task-info">
                          <span>本周内</span>
                          <span class="task-priority priority-low">低优先级</span>
                        </div>
                      </div>
                    </div>
                    <div class="task-item">
                      <div class="task-checkbox">
                        <el-checkbox v-model="task4"></el-checkbox>
                      </div>
                      <div class="task-content">
                        <div class="task-title">整理学生反馈报告</div>
                        <div class="task-info">
                          <span>10月20日前</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-card>

                <el-card style="margin-top: 20px;">
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon">
                        <el-icon size="24"><Clock /></el-icon>
                      </div>
                      <div class="card-title">最近活动</div>
                    </div>
                  </template>
                  <div class="recent-activity">
                    <div class="activity-item">
                      <div class="activity-avatar">
                        <el-icon><User /></el-icon>
                      </div>
                      <div class="activity-content">
                        <div class="activity-title">张老师更新了课程内容</div>
                        <div class="activity-time">10分钟前</div>
                      </div>
                    </div>
                    <div class="activity-item">
                      <div class="activity-avatar">
                        <el-icon><User /></el-icon>
                      </div>
                      <div class="activity-content">
                        <div class="activity-title">李老师提交了学生评估</div>
                        <div class="activity-time">1小时前</div>
                      </div>
                    </div>
                    <div class="activity-item">
                      <div class="activity-avatar">
                        <el-icon><User /></el-icon>
                      </div>
                      <div class="activity-content">
                        <div class="activity-title">系统进行了安全更新</div>
                        <div class="activity-time">3小时前</div>
                      </div>
                    </div>
                  </div>
                </el-card>
              </el-col>
            </el-row>

            <el-row :gutter="20" style="margin-top: 20px;">
              <el-col :span="8">
                <el-card>
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon" style="background: #36d1dc;">
                        <el-icon size="24"><Cpu /></el-icon>
                      </div>
                      <div class="card-title">系统状态</div>
                    </div>
                  </template>
                  <div class="system-status">
                    <div class="status-card">
                      <div class="status-icon" style="background: #36d1dc;">
                        <el-icon size="24"><Cpu /></el-icon>
                      </div>
                      <div class="status-content">
                        <div class="status-title">CPU 使用率</div>
                        <div class="status-value status-good">24%</div>
                      </div>
                    </div>
                    <div class="status-card">
                      <div class="status-icon" style="background: #5b86e5;">
                        <el-icon size="24"><Memory /></el-icon>
                      </div>
                      <div class="status-content">
                        <div class="status-title">内存使用</div>
                        <div class="status-value">1.8GB/4GB</div>
                      </div>
                    </div>
                    <div class="status-card">
                      <div class="status-icon" style="background: #ff6b6b;">
                        <el-icon size="24"><DataBoard /></el-icon>
                      </div>
                      <div class="status-content">
                        <div class="status-title">存储空间</div>
                        <div class="status-value">45.2GB/120GB</div>
                      </div>
                    </div>
                    <div class="status-card">
                      <div class="status-icon" style="background: #4ecdc4;">
                        <el-icon size="24"><Lock /></el-icon>
                      </div>
                      <div class="status-content">
                        <div class="status-title">安全状态</div>
                        <div class="status-value status-good">正常</div>
                      </div>
                    </div>
                  </div>
                </el-card>
              </el-col>
              <el-col :span="16">
                <el-card>
                  <template #header>
                    <div class="card-header">
                      <div class="card-icon" style="background: #ffbe0b;">
                        <el-icon size="24"><Calendar /></el-icon>
                      </div>
                      <div class="card-title">今日课程安排</div>
                    </div>
                  </template>
                  <div style="height: 200px; display: flex; align-items: center; justify-content: center; color: #999;">
                    <el-icon size="40" style="margin-right: 15px;"><Calendar /></el-icon>
                    <div>
                      <div style="font-size: 1.2rem; margin-bottom: 10px;">今日无课程安排</div>
                      <div>您今天没有课程安排，可以处理其他工作</div>
                    </div>
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </div>
        </el-tab-pane>
        <el-tab-pane label="数据配置" name="second">
          <div class="tab-content">
            <h3>数据配置面板</h3>
            <p>在这里进行系统数据配置和管理</p>
          </div>
        </el-tab-pane>
        <el-tab-pane label="权限管理" name="third">
          <div class="tab-content">
            <h3>权限管理面板</h3>
            <p>在这里管理系统用户权限和角色</p>
          </div>
        </el-tab-pane>
        <el-tab-pane label="任务中心" name="fourth">
          <div class="tab-content">
            <h3>任务管理中心</h3>
            <p>在这里查看和管理系统任务</p>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import MyEChart from "@/components/echart/MyEChart.vue";
import {
  PieChart,
  User,
  Notebook,
  Monitor,
  Grid,
  Message,
  Calendar,
  Document,
  DataAnalysis,
  Bell,
  InfoFilled,
  List,
  Clock,
  Cpu,
  DataBoard,
  Lock,
  Top,
  Bottom
} from "@element-plus/icons-vue";

const tabActive = ref('first');
const task1 = ref(false);
const task2 = ref(false);
const task3 = ref(false);
const task4 = ref(false);

// 获取当前日期和星期
const currentDate = computed(() => {
  const now = new Date();
  return now.toLocaleDateString('zh-CN', {
    year: 'numeric',
    month: 'long',
    day: 'numeric'
  });
});

const currentDay = computed(() => {
  const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  const now = new Date();
  return days[now.getDay()];
});

// 导航方法
const navigateTo = (page: string) => {
  console.log(`Navigating to ${page}`);
  // 实际项目中这里可以使用路由跳转
  // router.push({ name: page });
};
</script>

<style scoped lang="scss">
.dashboard-container {
  max-width: 1600px;
  margin: 20px auto;
  padding: 0 20px;
}

.welcome-section {
  background: linear-gradient(135deg, #36d1dc, #5b86e5);
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 25px;
  color: white;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;

  h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
  }

  p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
  }
}

.date-info {
  text-align: right;

  .date {
    font-size: 2.5rem;
    font-weight: 700;
  }

  .day {
    font-size: 1.3rem;
    opacity: 0.9;
  }
}

.tabs-container {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}

:deep(.el-tabs) {
  --el-tabs-header-height: 60px;
}

:deep(.el-tabs__header) {
  margin: 0;
  background: #f9fafc;
  padding: 0 20px;
}

:deep(.el-tabs__item) {
  height: 60px;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0 25px;
}

:deep(.el-tabs__nav-wrap::after) {
  height: 1px;
  background-color: #e4e7ed;
}

:deep(.el-tabs__active-bar) {
  height: 4px;
  border-radius: 2px;
}

.tab-content {
  padding: 25px;
}

.el-row {
  margin-bottom: 20px;
}

.el-col {
  padding: 10px;
}

.el-card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  }
}

:deep(.el-card__header) {
  padding: 20px;
  border-bottom: 1px solid #f0f2f5;
  background-color: #f9fafc;
  border-top-left-radius: 12px !important;
  border-top-right-radius: 12px !important;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;

  &.icon-user { background: #e6f7ff; color: #1890ff; }
  &.icon-statistic { background: #f6ffed; color: #52c41a; }
  &.icon-menu { background: #fff7e6; color: #fa8c16; }
  &.icon-horn { background: #f9f0ff; color: #722ed1; }
  &.icon-task { background: #f0f5ff; color: #2f54eb; }
  &.icon-chart { background: #e6fffb; color: #13c2c2; }
}

.card-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
}

:deep(.el-card__body) {
  padding: 20px;
  flex: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 15px;
}

.stat-item {
  background: #f8f9fc;
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;

  &:hover {
    background: #edf4ff;
    transform: translateY(-3px);
  }
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 5px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #333;
}

.stat-trend {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  margin-top: 3px;

  &.trend-up { color: #52c41a; }
  &.trend-down { color: #f5222d; }
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 10px;
}

.action-item {
  text-align: center;
  padding: 15px 10px;
  border-radius: 12px;
  background: #f8f9fc;
  transition: all 0.3s ease;
  cursor: pointer;

  &:hover {
    background: #edf4ff;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  }
}

.action-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.action-text {
  font-size: 0.95rem;
  color: #333;
  font-weight: 500;
}

.announcement-list {
  list-style: none;
  padding: 0;
}

.announcement-item {
  padding: 15px 0;
  border-bottom: 1px solid #f0f2f5;
  display: flex;
  gap: 15px;

  &:last-child {
    border-bottom: none;
  }
}

.announcement-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  margin-top: 4px;
}

.announcement-content {
  flex: 1;
}

.announcement-title {
  font-weight: 500;
  margin-bottom: 5px;
  color: #333;
}

.announcement-time {
  color: #999;
  font-size: 0.85rem;
}

.chart-container {
  height: 400px;
  width: 100%;
  margin-top: 15px;
}

.tasks-container {
  margin-top: 20px;
}

.task-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f2f5;

  &:last-child {
    border-bottom: none;
  }
}

.task-checkbox {
  margin-right: 12px;
}

.task-content {
  flex: 1;
}

.task-title {
  margin-bottom: 3px;
  font-weight: 500;
}

.task-info {
  display: flex;
  font-size: 0.85rem;
  color: #999;
}

.task-priority {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-left: 10px;

  &.priority-high { background: #fff1f0; color: #f5222d; }
  &.priority-medium { background: #fff7e6; color: #fa8c16; }
  &.priority-low { background: #f6ffed; color: #52c41a; }
}

.recent-activity {
  margin-top: 20px;
}

.activity-item {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid #f0f2f5;
  gap: 15px;

  &:last-child {
    border-bottom: none;
  }
}

.activity-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f5ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #2f54eb;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 500;
  margin-bottom: 3px;
}

.activity-time {
  color: #999;
  font-size: 0.85rem;
}

.system-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 20px;
}

.status-card {
  background: #f8f9fc;
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}

.status-content {
  flex: 1;
}

.status-title {
  font-weight: 500;
  margin-bottom: 5px;
}

.status-value {
  font-weight: 600;
  color: #333;

  &.status-good { color: #52c41a; }
  &.status-warning { color: #fa8c16; }
}

@media (max-width: 1200px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .welcome-section {
    flex-direction: column;
    text-align: center;
  }

  .date-info {
    text-align: center;
    margin-top: 20px;
  }
}

@media (max-width: 768px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .system-status {
    grid-template-columns: 1fr;
  }
}
</style>
